package
{
	import de.nulldesign.nd2d.display.World2D;
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.geom.Transform;
	import flash.geom.Vector3D;

	public class World
	{
		private var m_gameObjects:Vector.<GameObject>;
		private var m_config:WorldConfig;
		private var m_transformer:ITransformer;
		private var m_world:IWorld;
		
		public function World()
		{
			m_transformer = new IsometricTransformer();
			m_gameObjects = new Vector.<GameObject>;

			m_world = Globals.rendererFactory.getWorld();
		}
		
		public function setParent(parent:DisplayObjectContainer):void{
			parent.addChild(m_world as DisplayObject);
		}
		
		public function configure(config:WorldConfig):void{
			m_config = config;
			m_world.setCameraPosition(-500,-500);
		}
		
		public function add(gobj:GameObject):void{
			m_gameObjects.push(gobj);
			gobj.setParent(m_world.getScene());
			m_transformer.transform(gobj);
		}
		
		public function update():void{
			var i:int, il:int;
			for(i = 0, il = m_gameObjects.length; i < il; i++){
				m_transformer.transform(m_gameObjects[i]);
				m_gameObjects[i].update();
			}
		}

	}
}